home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Development / 3DMF parser / 0.9 version / MFTEXTUT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-21  |  1.8 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*==============================================================================
  2.  *
  3.  *    File:        MFTEXTUT.C
  4.  *
  5.  *    Function:    Text utility routines
  6.  *
  7.  *    Author(s):    Rick Wong (RWW)
  8.  *
  9.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  10.  *
  11.  *    Change History (most recent first):
  12.  *        Fabio    Changed file name to 8 characters
  13.  *        F3A_RWW    TOC stuff works.
  14.  *        F2G_RWW    File created.
  15.  *==============================================================================
  16.  */
  17. #include "MFTEXTUT.H"
  18.  
  19. #include <ctype.h>            /* tolower */
  20.  
  21. #include "MFSYSTYP.H"
  22. #include "MFTYPES.H"
  23. #include "MFASSERT.H"
  24. #include "MFMEMORY.H"
  25.  
  26. /*==============================================================================
  27.  *    MF3D_CmpStrInsensitive
  28.  *
  29.  *    Case-insensitive comparison of two strings.
  30.  *
  31.  *    Return 0 for a match; nonzero otherwise.
  32.  *==============================================================================
  33.  */
  34. MF3DInt32
  35. MF3D_CmpStrInsensitive(
  36.     const char        *string1,
  37.     const char        *string2)
  38. {
  39.     MF3DInt32        result;
  40.  
  41.     MFASSERT(string1 != NULL && string2 != NULL);
  42.  
  43.     while((result = (tolower(*string1) - tolower(*string2))) == 0 &&
  44.             *string1++ != '\0' && *string2++ != '\0')
  45.     {
  46.     }
  47.  
  48.     return result;
  49. }
  50.  
  51. /*==============================================================================
  52.  *    MF3D_DuplicateCString
  53.  *
  54.  *    Make a copy of a CStringPtr by allocating another pointer of the same size.
  55.  *==============================================================================
  56.  */
  57. MF3DCStringPtr
  58. MF3D_DuplicateCString(
  59.     MF3DCStringPtr    inStringPtr)        /* s.b. const */
  60. {
  61.     MF3DCStringPtr    result;
  62.     MF3DUns32        stringLen;
  63.     MF3DCStringPtr    pdst, psrc;
  64.  
  65.     if (inStringPtr == NULL)
  66.         return NULL;
  67.  
  68.     stringLen = CStringLen(inStringPtr);
  69.  
  70.     result = MF3D_Malloc(stringLen + 1);
  71.  
  72.     if (result != NULL)
  73.     {    pdst = result;
  74.         psrc = inStringPtr;
  75.  
  76.         while (*pdst++ = *psrc++)
  77.             ;
  78.     }
  79.  
  80.     return result;
  81. }
  82.